<?php
/**
 * mini object:
 * data collection
 * for small objects of
 * data
 */
class Blib_Data_Collection
{
    /**
     * data storage
     * @var array
     */
    protected $_data = array();


    /**
     * constructor
     * @param array $params initial params
     * @return void
     */
    public function __construct($params = array())
    {
        $this->_data = (array) $params;

    }// end construct


    /**
     * add data
     * @param str $k the key
     * @param mixed $v the value
     * @return this
     */
    public function add($k, $v)
    {
        $this->_data[$k] = $v;
        return $this;

    }// end add


    /**
     * add multiple data
     * @param array $params list of params to add
     * @return this
     */
    public function addMulti($params)
    {
        $this->_data = array_merge($this->_data, $params);
        return $this;

    }// end add


    /**
     * get data
     * @param str $k the key
     * @param mixed $default default value
     * @return mixed
     */
    public function get($k, $default = null)
    {
        if (!empty($this->_data[$k])) {
            return $this->_data[$k];
        }

        return $default;

    }// end get


    /**
     * remove by key name
     * @param str $k the key
     * @return self
     */
    public function remove($k)
    {
        if (isset($this->_data[$k])) {
            unset($this->_data[$k]);
        }
        return $this;

    }// end remove


    /**
     * force clear vals
     * @return this
     */
    public function clearAll()
    {
        $this->_data = array();
        return $this;

    }// end clearAll

}// end Blib_Data_Collection
?>